package com.zf.springdoc.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author Zhou Feng
 */
@Tag(name = "问候")
@RestController
@RequestMapping("/hello")
public class HelloController {

    @Operation(summary = "欢迎")
    @GetMapping("/welcome")
    public String welcome() {
        return "hello world";
    }
    @Operation(summary = "欢迎")
    @GetMapping("/welcomeKey")
    public String welcome(@Parameter(name = "key", description = "key") @RequestParam(name = "key") String key) {
        String result = "hello world"+key;
        return result;
    }

    @GetMapping("/price")
    public BigDecimal price(@RequestParam Long skuId) throws Exception {
        if (skuId < 0) {
            throw new Exception("商品不存在");
        }
        return BigDecimal.valueOf(100);
    }
}
